package zencstudio.sgrealtor.adapter;

import java.util.List;

import zencstudio.sgrealtor.R;
import zencstudio.sgrealtor.model.Course;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;



public class CourseListAdapter extends BaseAdapter{

	private List<Course>listCourse;
	private Context context;
	public CourseListAdapter(Context context) {
		this.context = context;
	}
	@Override
	public int getCount() {
		return listCourse.size();
	}

	@Override
	public Object getItem(int arg0) {
		return listCourse.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int arg0, View convertView, ViewGroup arg2) {
		Course c = (Course) getItem(arg0);
		LayoutInflater inflater = 
	              (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		if(convertView == null){
			convertView = inflater.inflate(R.layout.course_item, arg2,false);
		}
		TextView txtView = (TextView) convertView.findViewById(R.id.txtName);
		txtView.setText(c.getName());
		txtView = (TextView) convertView.findViewById(R.id.txtDate);
		txtView.setText(c.getDate());
		txtView = (TextView) convertView.findViewById(R.id.txtPrice);
		txtView.setText(c.getPrice()+" $");
		return convertView;
	}
	public List<Course> getListCourse() {
		return listCourse;
	}
	public void setListCourse(List<Course> listCourse) {
		this.listCourse = listCourse;
	}
	public void addCourse(Course c){
		this.listCourse.add(c);
	}
	public Context getContext() {
		return context;
	}
	public void setContext(Context context) {
		this.context = context;
	}

}
